#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 vagrant
#
# Distributed under terms of the MIT license.

from django.core.management.base import BaseCommand, CommandError, NoArgsCommand
from spider import shortcuts


class Command(BaseCommand):

    def add_arguments(self, parser):
        parser.add_argument('spider', type=str)
        parser.add_argument('url', type=str)

    def handle(self, *args, **options):
        spider_name = options.get('spider')
        url = options.get('url')
        spider = shortcuts.get_spider(spider_name)
        shortcuts.add_spider_testcase(spider, url)
